import heapq
direct = [(-2,1),(-1,2),(1,2),(2,1),(2,-1),(1,-2),(-1,-2),(-2,-1)]

def dist(start, end):
    return ((start[0]-end[0])**2+(start[1]-end[1])**2)**0.5

def bfs_dist(start, end):
    hq = []
    heapq.heappush(hq, (dist(start, end), start))
    step = {start : 0}
    
    while hq:
        cur_dist, cur = heapq.heappop(hq)
        if cur == end:
            return step[cur]
            
        for i,j in direct:
            next_x = cur[0] + i
            next_y = cur[1] + j
            
            if 0<next_x<=1000 and 0<next_y<=1000 :
                # next_dist = dist(start, (next_x, next_y)) + dist((next_x, next_y), end)
                if step[cur]+1 < step.get((next_x, next_y), float('inf')):
                    step[(next_x, next_y)] = step[cur]+1
                    heapq.heappush(hq, (dist((next_x, next_y), end)+step[(next_x, next_y)], (next_x, next_y)))
                
                
def main():
    N = int(input())
    for i in range(N):
        start_x, start_y, end_x, end_y = map(int, input().split())
        
        print(bfs_dist((start_x,start_y), (end_x, end_y)))
    
main()
        